The zoomable background drawn as a floor that runs away to a horizon, the way a racing game draws its road - set by code, with objects that stand on it, redrawn row by row by the console.
A zoomable background normally zooms and turns as one flat picture. With the perspective floor on, the same picture is drawn as a floor seen from a camera standing over it: the part under the camera is large, the part far ahead is small and thin, and it all runs away to a horizon. It is how a racing game draws a track from one big picture, and it works for anything laid flat: a sea, a desert, a battlefield, a corridor.
It is beside the plain zoom, never instead of it. Turn the floor off and the picture is the flat zoomable background again.
There is no room setting and no editor control: the floor is started by code, in the Create event of the object that runs the race.
perspective_floor(true);
perspective_floor_horizon(54);
perspective_floor_height(24);
perspective_floor_view(90);perspective_floor_camera(cam_x, cam_y, heading);| Call | What it sets |
|---|---|
perspective_floor_camera(x, y, heading) | Where the camera stands on the picture (the picture's own pixels, from its top-left corner) and which way it looks (degrees, 0 looks up the picture, counter-clockwise) |
perspective_floor_height | How high the camera is above the picture. Higher shows more floor and makes the road look smaller |
perspective_floor_horizon | The screen row, from the top, where the floor starts. Rows above it show the room's other pictures |
perspective_floor_view | How wide the camera sees across the screen, in degrees. Wide stretches the road sideways |
Give an object floor places for its x and y: picture pixels. Then everything that works in the room works on the floor, whatever the camera does: collision_rect, masks, dist_to, motion. Put it on the screen from its Draw event:
draw_self_on_floor draws the instance's own sprite where the floor shows its place, scaled smoothly by distance, nearer in front.draw_sprite_on_floor draws any sprite at a chosen size. Ask floor_scale_at how big the place looks and pick a picture: drawn size steps (a 64, a 32 and a 16 wide car), never a scaled big picture, so near cars stay sharp and cost no turn-and-size slot. The sprite's origin is its feet.perspective_floor_project and its answers are the lower-level pieces, and perspective_floor_ahead says how far ahead of the camera a place is.Set the object's Release off view off (an object outside the screen is otherwise released), and give the room the picture's size.
zoom_background_repeat) fills those rows with itself.